#pragma once

#include <gl/glew.h>
#define GLFW_DLL
#include <gl/glfw.h>

#include <dirent.h>
#include <fstream>
#include <iostream>
#include <map>
#include <memory>
#include <string>
#include <vector>

#include "model.h"

#include "entities/building.h"
#include "entities/terrainfeature.h"
#include "entities/terraintype.h"
#include "entities/unit.h"

class ResourceManager{
    public:
        ResourceManager(){}

        void LoadAllData();

        void LoadAllResources();
        void LoadResource(std::string filename);
        void LoadAllBuildings();
        void LoadBuilding(std::string filename);
        void LoadAllUnits();
        void LoadUnit(std::string filename);
        void LoadAllTerrain();
        void LoadTerrain(std::string filename);
        void LoadAllResearch();
        void LoadResearch(std::string filename);
        void LoadModel(std::string name, std::string path);

        Entity* GetEntity(std::string name);

        Building* GetBuilding(std::string name);
        Model* GetModel(std::string name);
        TerrainType* GetTerrainType(std::string name);
        std::vector<TerrainType*> GetAllTerrainTypes();
        TerrainFeature* GetTerrainFeature(std::string name);
        Unit* GetUnit(std::string name);

        GLuint LoadTexture(std::string name, std::string filename);

        GLuint GetTexture(std::string);

    protected:
        std::map<std::string,std::unique_ptr<Building>> buildings;
        std::map<std::string,std::unique_ptr<Model>> models;
        std::map<std::string,std::unique_ptr<TerrainFeature>> terrainFeatures;
        std::map<std::string,std::unique_ptr<TerrainType>> terrainTypes;
        std::map<std::string,std::unique_ptr<Unit>> units;

        std::map<std::string,GLuint> textures;
};

extern ResourceManager* resourceManager;
